// packageH/pages/farmTicket/farmTicket.js
let app = getApp();
var applet_park_api_url = app.globalData.applet_park_api_url;
var applet_park_api_url_imgUrl = app.globalData.applet_park_api_url_imgUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banners: [],
    imgUrl: applet_park_api_url_imgUrl,
    tickets: ["", ""],
    farmId: 1,
    farmInfos: '',
    knowIsOpen: false,
    purchaseNotion: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.data.farmId = options.farmId;
    that.getInfo();
  },
  getInfo() {
    var that = this;
    wx.request({
      url: applet_park_api_url + '/api/farmTicket/farmAndTickets/' + that.data.farmId,
      success: function (res) {
        if (res.data.code == 0) {
          that.setData({
            banners: res.data.data.farm.banner.split(','),
            tickets: res.data.data.tickets,
            farmInfos: res.data.data.farm
          })
        } else {
          wx.showToast({
            title: res.data,
          })
        }
      },
      fail: function (res) {
        wx.showToast({
          title: res.data,
        })
      }
    })
  },
  openKnow(e) {
    var that = this;
    that.setData({
      purchaseNotion: that.data.tickets[e.currentTarget.dataset.ticketid-1].purchaseNotion
    })
    that.setData({
      knowIsOpen: true
    })
  },
  closeKnow() {
    var that = this;
    that.setData({
      knowIsOpen: false
    })
  },
  goBuy(e) {
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})